﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using YJKArchUtils.Utils;
using YJKRevitKernel.RevitTopologySuite;
using YJKRevitDimensionText.OneKeyPlanDim.DimData;
using YJKRevitDimensionText.OneKeyPlanDim.Utility;

namespace YJKRevitDimensionText.OneKeyPlanDim.LevelDim.Data
{
	public class CommonLayerFloor
	{
		public CommonLayerFloor(Autodesk.Revit.DB.Document doc)
		{
			this.m_doc = doc;
		}

		public PlanarFace ComponentInSlopePlanarFace
		{
			set
			{
				this.m_ComponentInSlopePlanarFace = value;
			}
		}

		public string LevelVal
		{
			get
			{
				return this.m_dLevelVal.ToString("f3");
			}
		}

		public double dLevelVal
		{
			get
			{
				return this.m_dLevelVal;
			}
			set
			{
				this.m_dLevelVal = value;
			}
		}

		public bool IsCurrentLay
		{
			get
			{
				return this.m_bIsCurrentLay;
			}
			set
			{
				this.m_bIsCurrentLay = value;
			}
		}

		public void AddFloor(FloorGeometry floorGeometry)
		{
			this.m_lstFloorGeometry.Add(floorGeometry);
		}

		public void CreateLevelDim()
		{
			if (this.m_lstFloorGeometry.Count > 0)
			{
				this.dLevelVal = this.m_lstFloorGeometry[0].m_dLevelVal;
			}
			List<SingleLevelDimDataInfo> dimPosition = new List<SingleLevelDimDataInfo>();
			List<List<Curve>> list = new List<List<Curve>>();
			foreach (FloorGeometry floorGeometry in this.m_lstFloorGeometry)
			{
				list.Add(floorGeometry.m_lstBaseCv);
			}
			this.CreateKeyComponent(ref dimPosition, list);
			this.SetDimPosition(this.m_lstHouseSingleDimDataInfo);
			this.SetDimPosition(dimPosition);
			foreach (SingleLevelDimDataInfo singleLevelDimDataInfo in this.m_lstHouseSingleDimDataInfo)
			{
				KeyComponent.GetInstance().m_lstLevelDimension.Add(singleLevelDimDataInfo.AnnotationSymbol);
			}
		}

		public void SetDimPosition(List<SingleLevelDimDataInfo> lstSingleDimDataInfo)
		{
			foreach (SingleLevelDimDataInfo singleLevelDimDataInfo in lstSingleDimDataInfo)
			{
				AnnotationSymbol annotationSymbol = singleLevelDimDataInfo.AnnotationSymbol;
				if (annotationSymbol != null)
				{
					CurveLoop curveLoop = OcclusionArea.GetLevelDimCurveLoop(this.m_doc, annotationSymbol);
					XYZ ptLocation = singleLevelDimDataInfo.PtLocation;
					XYZ ptEnd = ptLocation;
					List<CurveLoop> list = new List<CurveLoop>();
					ElementId elemId = ElementId.InvalidElementId;
					if (singleLevelDimDataInfo.m_LstElementId.Count > 0)
					{
						elemId = singleLevelDimDataInfo.m_LstElementId[0];
					}
					list.AddRange(OcclusionArea.GetInstance().AllComponentOcclusionAreaExistRampById(elemId));
					for (int i = 0; i < 17; i++)
					{
						ptEnd = CommonInterface.GetNumCorrespondingOffsetPoint(16, i, Common.MMToFeet(600.0), ptLocation);
						CurveLoop curveLoop2 = CommonInterface.MoveCurve(curveLoop, ptLocation, ptEnd);
						if (!CommonInterface.IsExistOcclusion(curveLoop2, list))
						{
							curveLoop = curveLoop2;
							break;
						}
						if (16 == i)
						{
							ptEnd = ptLocation;
							break;
						}
					}
					CommonInterface.MoveElement(annotationSymbol, ptLocation, ptEnd, this.m_doc);
					OcclusionArea.GetInstance().m_lstLevelDimCvLoop.Add(curveLoop);
				}
			}
		}

		private List<SingleLevelDimDataInfo> CreateDimIfNoComponentOutArch()
		{
			List<SingleLevelDimDataInfo> list = new List<SingleLevelDimDataInfo>();
			foreach (FloorGeometry floorGeometry in this.m_lstFloorGeometry)
			{
				XYZ xyz = GeometryHelper.GeometricCenterByLstCv(GeometryHelper.GetAllEdgeList(floorGeometry.m_planarFace));
				if (!GeometryHelper.IsInCvLoop(new XYZ(xyz.X, xyz.Y, 0.0), KeyComponent.GetInstance().m_lstOutWallCurves))
				{
					FamilyInstance familyInstance = new LevelDimData(this.m_doc)
					{
						PtDimLocation = xyz,
						DimVal = this.LevelVal
					}.CreateLevelDim();
					if (familyInstance != null)
					{
						AnnotationSymbol annotationSymbol = familyInstance as AnnotationSymbol;
						if (annotationSymbol != null)
						{
							list.Add(new SingleLevelDimDataInfo(annotationSymbol)
							{
								LevelVal = this.m_lstFloorGeometry[0].m_dLevelVal,
								DimDir = XYZ.BasisX,
								PtLocation = xyz
							});
						}
					}
				}
			}
			return list;
		}

		private List<SingleLevelDimDataInfo> CreateDimIfNoComponentInArch()
		{
			List<SingleLevelDimDataInfo> list = new List<SingleLevelDimDataInfo>();
			if (this.m_bIsCurrentLay)
			{
				double num = double.MinValue;
				FloorGeometry floorGeometry = null;
				foreach (FloorGeometry floorGeometry2 in this.m_lstFloorGeometry)
				{
					XYZ xyz = GeometryHelper.GeometricCenterByLstCv(GeometryHelper.GetAllEdgeList(floorGeometry2.m_planarFace));
					if (GeometryHelper.IsInCvLoop(new XYZ(xyz.X, xyz.Y, 0.0), KeyComponent.GetInstance().m_lstOutWallCurves) && Geometry.LessThan(num, floorGeometry2.m_planarFace.Area))
					{
						num = floorGeometry2.m_planarFace.Area;
						floorGeometry = floorGeometry2;
					}
				}
				if (floorGeometry != null)
				{
					List<Room> list2 = this.RoomOnFloor(floorGeometry);
					double minValue = double.MinValue;
					Room room = null;
					foreach (Room room2 in list2)
					{
						if (Geometry.LessThan(minValue, room2.Area))
						{
							num = room2.Area;
							room = room2;
						}
					}
					if (room != null)
					{
						list.AddRange(this.CreateRoomLevelDim(room, this.LevelVal));
					}
				}
			}
			else
			{
				foreach (FloorGeometry floorGeometry3 in this.m_lstFloorGeometry)
				{
					List<Room> list3 = this.RoomOnFloor(floorGeometry3);
					if (list3.Count > 0)
					{
						using (List<Room>.Enumerator enumerator2 = list3.GetEnumerator())
						{
							while (enumerator2.MoveNext())
							{
								Room room3 = enumerator2.Current;
								list.AddRange(this.CreateRoomLevelDim(room3, this.LevelVal));
							}
							continue;
						}
					}
					List<Curve> allEdgeList = GeometryHelper.GetAllEdgeList(floorGeometry3.m_planarFace);
					foreach (RevitOperationDataBean revitOperationDataBean in GeometryHelper.GetIntersection(KeyComponent.GetInstance().m_lstOutWallCurves, allEdgeList, 0))
					{
						if (revitOperationDataBean != null)
						{
							XYZ xyz2 = GeometryHelper.GeometricCenterByLstCv(revitOperationDataBean.LstRevitCurve);
							FamilyInstance familyInstance = new LevelDimData(this.m_doc)
							{
								PtDimLocation = xyz2,
								DimVal = this.LevelVal
							}.CreateLevelDim();
							if (familyInstance != null)
							{
								CurveLoop levelDimCurveLoop = OcclusionArea.GetLevelDimCurveLoop(this.m_doc, familyInstance);
								this.m_lstAllCurLayerCurveLoop.Add(levelDimCurveLoop);
								AnnotationSymbol annotationSymbol = familyInstance as AnnotationSymbol;
								if (annotationSymbol != null)
								{
									list.Add(new SingleLevelDimDataInfo(annotationSymbol)
									{
										LevelVal = this.m_lstFloorGeometry[0].m_dLevelVal,
										DimDir = XYZ.BasisX,
										PtLocation = xyz2
									});
								}
							}
						}
					}
				}
			}
			return list;
		}

		private List<Room> RoomOnFloor(FloorGeometry floorGeometry)
		{
			List<Room> list = new List<Room>();
			foreach (Room room in this.m_lstCurrentLayRoom)
			{
				LocationPoint locationPoint = room.Location as LocationPoint;
				if (locationPoint != null && GeometryHelper.PointOnFloor(locationPoint.Point, floorGeometry.m_lstBaseCv))
				{
					list.Add(room);
				}
			}
			return list;
		}

		public void CreateKeyComponent(ref List<SingleLevelDimDataInfo> lstAllSingleDimDataInfo, List<List<Curve>> lstlstCv)
		{
			List<DbSteps> dbStepsOnFloors = this.GetDbStepsOnFloors(lstlstCv);
			List<DbCarRamp> dbCarRampOnFloors = this.GetDbCarRampOnFloors(lstlstCv);
			List<DbRevitRamp> dbRevitRampOnFloors = this.GetDbRevitRampOnFloors(lstlstCv);
			List<DbRampByDoor> dbRampByDoorOnFloors = this.GetDbRampByDoorOnFloors(lstlstCv);
			List<DbBarrierFreeRamp> dbBarrierFreeRampOnFloors = this.GetDbBarrierFreeRampOnFloors(lstlstCv);
			List<DbSlopeFloor> dbSlopeFloorOnFloors = this.GetDbSlopeFloorOnFloors(lstlstCv);
			List<DbCanopy> dbCanopyFloorOnFloors = this.GetDbCanopyFloorOnFloors(lstlstCv);
			if (OneKeyPlanDimSelctionDim.m_bInArchLevel)
			{
				List<SingleLevelDimDataInfo> list = new List<SingleLevelDimDataInfo>();
				this.m_lstCurrentLayRoom = this.GetRoomsOnFloors();
				this.m_lstHouseSingleDimDataInfo.AddRange(this.CreateSpecialRoomLevelDim(this.m_lstCurrentLayRoom));
				list.AddRange(this.CreateKeyRoomLevelDim(this.m_lstCurrentLayRoom));
				list.AddRange(this.CreateDbDimBaseLevelDim<DbSteps>(dbStepsOnFloors, false));
				list.AddRange(this.CreateDbDimBaseLevelDim<DbCarRamp>(dbCarRampOnFloors, false));
				list.AddRange(this.CreateDbDimBaseLevelDim<DbRevitRamp>(dbRevitRampOnFloors, false));
				list.AddRange(this.CreateDbDimBaseLevelDim<DbRampByDoor>(dbRampByDoorOnFloors, false));
				list.AddRange(this.CreateDbDimBaseLevelDim<DbBarrierFreeRamp>(dbBarrierFreeRampOnFloors, false));
				list.AddRange(this.CreateDbDimBaseLevelDim<DbSlopeFloor>(dbSlopeFloorOnFloors, false));
				list.AddRange(this.CreateDbDimBaseLevelDim<DbCanopy>(dbCanopyFloorOnFloors, false));
				if (list.Count == 0)
				{
					list.AddRange(this.CreateDimIfNoComponentInArch());
				}
				this.DelRepeatDim(ref this.m_lstHouseSingleDimDataInfo, ref list, Common.MMToFeet(10000.0));
				this.DelRepeatDim(ref list, Common.MMToFeet(10000.0));
				lstAllSingleDimDataInfo.AddRange(list);
			}
			if (OneKeyPlanDimSelctionDim.m_bOutArchLevel)
			{
				List<SingleLevelDimDataInfo> list2 = this.CreateDbDimBaseLevelDim<DbSteps>(dbStepsOnFloors, true);
				list2.AddRange(this.CreateDbDimBaseLevelDim<DbCarRamp>(dbCarRampOnFloors, true));
				list2.AddRange(this.CreateDbDimBaseLevelDim<DbRevitRamp>(dbRevitRampOnFloors, true));
				list2.AddRange(this.CreateDbDimBaseLevelDim<DbRampByDoor>(dbRampByDoorOnFloors, true));
				list2.AddRange(this.CreateDbDimBaseLevelDim<DbBarrierFreeRamp>(dbBarrierFreeRampOnFloors, true));
				list2.AddRange(this.CreateDbDimBaseLevelDim<DbSlopeFloor>(dbSlopeFloorOnFloors, true));
				list2.AddRange(this.CreateDbDimBaseLevelDim<DbCanopy>(dbCanopyFloorOnFloors, true));
				if (list2.Count == 0)
				{
					list2.AddRange(this.CreateDimIfNoComponentOutArch());
				}
				this.DelRepeatDim(ref list2, Common.MMToFeet(20000.0));
				lstAllSingleDimDataInfo.AddRange(list2);
			}
			foreach (SingleLevelDimDataInfo singleLevelDimDataInfo in lstAllSingleDimDataInfo)
			{
				KeyComponent.GetInstance().m_lstLevelDimension.Add(singleLevelDimDataInfo.AnnotationSymbol);
			}
		}

		private void DelRepeatDim(ref List<SingleLevelDimDataInfo> lstSpecialHouseSingleDimDataInfo, ref List<SingleLevelDimDataInfo> lstAllSingleDimDataInfo, double dLength)
		{
			foreach (SingleLevelDimDataInfo singleLevelDimDataInfo in lstSpecialHouseSingleDimDataInfo)
			{
				for (int i = 0; i < lstAllSingleDimDataInfo.Count; i++)
				{
					if (singleLevelDimDataInfo.IsRepeatabilityJudg(lstAllSingleDimDataInfo[i], dLength))
					{
						lstAllSingleDimDataInfo[i].DelLevelDim(this.m_doc);
						lstAllSingleDimDataInfo.RemoveAt(i);
						i--;
					}
				}
			}
		}

		private void DelRepeatDim(ref List<SingleLevelDimDataInfo> lstAllSingleDimDataInfo, double dLength)
		{
			for (int i = 0; i < lstAllSingleDimDataInfo.Count; i++)
			{
				for (int j = i + 1; j < lstAllSingleDimDataInfo.Count; j++)
				{
					if (lstAllSingleDimDataInfo[i].IsRepeatabilityJudg(lstAllSingleDimDataInfo[j], dLength))
					{
						lstAllSingleDimDataInfo[j].DelLevelDim(this.m_doc);
						lstAllSingleDimDataInfo.RemoveAt(j);
						j--;
					}
				}
			}
		}

		private List<DbSteps> GetDbStepsOnFloors(List<List<Curve>> lstlstBaseCv)
		{
			List<DbSteps> list = new List<DbSteps>();
			foreach (DbSteps dbSteps in KeyComponent.GetInstance().m_AllDbSteps)
			{
				if (!dbSteps.IsLevelDimed)
				{
					XYZ centerPoint = dbSteps.CenterPoint;
					foreach (List<Curve> lstCv in lstlstBaseCv)
					{
						if (GeometryHelper.PointOnFloor(centerPoint, lstCv))
						{
							dbSteps.ComponentInSlopePlanarFace = this.m_ComponentInSlopePlanarFace;
							list.Add(dbSteps);
							break;
						}
					}
				}
			}
			return list;
		}

		private List<DbCarRamp> GetDbCarRampOnFloors(List<List<Curve>> lstlstBaseCv)
		{
			List<DbCarRamp> list = new List<DbCarRamp>();
			foreach (DbCarRamp dbCarRamp in KeyComponent.GetInstance().m_AllDbCarRamp)
			{
				if (!dbCarRamp.IsLevelDimed)
				{
					List<Curve> centerLineList = dbCarRamp.CenterLineList;
					if (centerLineList != null && centerLineList.Count != 0)
					{
						XYZ ptOld = (centerLineList[0].GetEndPoint(0) + centerLineList[0].GetEndPoint(1)) / 2.0;
						foreach (List<Curve> lstCv in lstlstBaseCv)
						{
							if (GeometryHelper.PointOnFloor(ptOld, lstCv))
							{
								dbCarRamp.ComponentInSlopePlanarFace = this.m_ComponentInSlopePlanarFace;
								list.Add(dbCarRamp);
								break;
							}
						}
					}
				}
			}
			return list;
		}

		private List<DbRevitRamp> GetDbRevitRampOnFloors(List<List<Curve>> lstlstBaseCv)
		{
			List<DbRevitRamp> list = new List<DbRevitRamp>();
			foreach (DbRevitRamp dbRevitRamp in KeyComponent.GetInstance().m_AllDbRevitRamp)
			{
				if (!dbRevitRamp.IsLevelDimed)
				{
					XYZ centerPoint = dbRevitRamp.CenterPoint;
					foreach (List<Curve> lstCv in lstlstBaseCv)
					{
						if (GeometryHelper.PointOnFloor(centerPoint, lstCv))
						{
							dbRevitRamp.ComponentInSlopePlanarFace = this.m_ComponentInSlopePlanarFace;
							list.Add(dbRevitRamp);
							break;
						}
					}
				}
			}
			return list;
		}

		private List<DbRampByDoor> GetDbRampByDoorOnFloors(List<List<Curve>> lstlstBaseCv)
		{
			List<DbRampByDoor> list = new List<DbRampByDoor>();
			foreach (DbRampByDoor dbRampByDoor in KeyComponent.GetInstance().m_AllDbRampByDoor)
			{
				if (!dbRampByDoor.IsLevelDimed)
				{
					XYZ centerPoint = dbRampByDoor.CenterPoint;
					foreach (List<Curve> lstCv in lstlstBaseCv)
					{
						if (GeometryHelper.PointOnFloor(centerPoint, lstCv))
						{
							dbRampByDoor.ComponentInSlopePlanarFace = this.m_ComponentInSlopePlanarFace;
							list.Add(dbRampByDoor);
							break;
						}
					}
				}
			}
			return list;
		}

		private List<DbBarrierFreeRamp> GetDbBarrierFreeRampOnFloors(List<List<Curve>> lstlstBaseCv)
		{
			List<DbBarrierFreeRamp> list = new List<DbBarrierFreeRamp>();
			foreach (DbBarrierFreeRamp dbBarrierFreeRamp in KeyComponent.GetInstance().m_AllDbBarrierFreeRamp)
			{
				if (!dbBarrierFreeRamp.IsLevelDimed)
				{
					Line slopeStartLine = dbBarrierFreeRamp.SlopeStartLine;
					if (!(slopeStartLine == null))
					{
						XYZ ptOld = (slopeStartLine.GetEndPoint(0) + slopeStartLine.GetEndPoint(1)) / 2.0;
						foreach (List<Curve> lstCv in lstlstBaseCv)
						{
							if (GeometryHelper.PointOnFloor(ptOld, lstCv))
							{
								dbBarrierFreeRamp.ComponentInSlopePlanarFace = this.m_ComponentInSlopePlanarFace;
								list.Add(dbBarrierFreeRamp);
								break;
							}
						}
					}
				}
			}
			return list;
		}

		private List<DbSlopeFloor> GetDbSlopeFloorOnFloors(List<List<Curve>> lstlstBaseCv)
		{
			List<DbSlopeFloor> list = new List<DbSlopeFloor>();
			foreach (DbSlopeFloor dbSlopeFloor in KeyComponent.GetInstance().m_AllDbSlopeFloor)
			{
				if (!dbSlopeFloor.IsLevelDimed)
				{
					XYZ centerPoint = dbSlopeFloor.CenterPoint;
					foreach (List<Curve> lstCv in lstlstBaseCv)
					{
						if (GeometryHelper.PointOnFloor(centerPoint, lstCv))
						{
							dbSlopeFloor.ComponentInSlopePlanarFace = this.m_ComponentInSlopePlanarFace;
							list.Add(dbSlopeFloor);
							break;
						}
					}
				}
			}
			return list;
		}

		private List<DbCanopy> GetDbCanopyFloorOnFloors(List<List<Curve>> lstlstBaseCv)
		{
			List<DbCanopy> list = new List<DbCanopy>();
			foreach (DbCanopy dbCanopy in KeyComponent.GetInstance().m_lstDbCanopy)
			{
				if (!dbCanopy.IsLevelDimed)
				{
					XYZ centerPoint = dbCanopy.CenterPoint;
					foreach (List<Curve> lstCv in lstlstBaseCv)
					{
						if (GeometryHelper.PointOnFloor(centerPoint, lstCv))
						{
							dbCanopy.ComponentInSlopePlanarFace = this.m_ComponentInSlopePlanarFace;
							list.Add(dbCanopy);
							break;
						}
					}
				}
			}
			return list;
		}

		private List<Room> GetRoomsOnFloors()
		{
			List<Room> list = new List<Room>();
			foreach (DbRoom dbRoom in KeyComponent.GetInstance().m_AllRoom)
			{
				if (!dbRoom.IsLevelDimed)
				{
					LocationPoint locationPoint = dbRoom.GetRoom.Location as LocationPoint;
					if (locationPoint != null)
					{
						foreach (FloorGeometry floorGeometry in this.m_lstFloorGeometry)
						{
							if (GeometryHelper.PointOnFloor(locationPoint.Point, floorGeometry.m_lstBaseCv))
							{
								dbRoom.IsLevelDimed = true;
								list.Add(dbRoom.GetRoom);
								break;
							}
						}
					}
				}
			}
			return list;
		}

		private List<SingleLevelDimDataInfo> CreateDbDimBaseLevelDim<T>(List<T> lstDbDimBase, bool bIsOutArch) where T : DbDimBase
		{
			List<SingleLevelDimDataInfo> list = new List<SingleLevelDimDataInfo>();
			foreach (T t in lstDbDimBase)
			{
				if ((t.IsOutArch && bIsOutArch) || (!t.IsOutArch && !bIsOutArch))
				{
					t.dFloorLevelVal = this.dLevelVal;
					List<SingleLevelDimDataInfo> collection = new List<SingleLevelDimDataInfo>();
					if (t.CreateLevelDim(this.m_doc, out collection))
					{
						list.AddRange(collection);
					}
				}
			}
			if (list.Count > 0 && lstDbDimBase.Count > 0 && lstDbDimBase[0] is DbSteps)
			{
				this.MergeStepDownDim(list);
			}
			SortLevelDimDataInfo sortLevelDimDataInfo = new SortLevelDimDataInfo(list);
			sortLevelDimDataInfo.SortOperator();
			return sortLevelDimDataInfo.SingleLevelDimDataInfo;
		}

		private void MergeStepDownDim(List<SingleLevelDimDataInfo> lstAllSingleLevelDimDataInfo)
		{
			List<SingleLevelDimDataInfo> list = new List<SingleLevelDimDataInfo>();
			for (int i = 0; i < lstAllSingleLevelDimDataInfo.Count; i++)
			{
				for (int j = i + 1; j < lstAllSingleLevelDimDataInfo.Count; j++)
				{
					if (lstAllSingleLevelDimDataInfo[i].MergeSingleLevelDimDataInfo(this.m_doc, lstAllSingleLevelDimDataInfo[j]))
					{
						list.Add(lstAllSingleLevelDimDataInfo[j]);
						lstAllSingleLevelDimDataInfo.RemoveAt(j);
						j--;
					}
				}
			}
			if (list.Count > 0)
			{
				List<ElementId> list2 = new List<ElementId>();
				foreach (SingleLevelDimDataInfo singleLevelDimDataInfo in list)
				{
					if (singleLevelDimDataInfo.AnnotationSymbol.IsValidObject)
					{
						list2.Add(singleLevelDimDataInfo.AnnotationSymbol.Id);
					}
				}
				Transaction transaction = new Transaction(this.m_doc, "DelStepDim");
				try
				{
					transaction.Start();
					this.m_doc.Delete(list2);
					transaction.Commit();
				}
				catch
				{
					transaction.RollBack();
				}
			}
		}

		private List<SingleLevelDimDataInfo> CreateSpecialRoomLevelDim(List<Room> lstCurrentLayRoom)
		{
			List<SingleLevelDimDataInfo> list = new List<SingleLevelDimDataInfo>();
			string strRoomName = "厕_男卫_女卫_残卫_盥洗_洗手间_更衣室_淋浴间_卫生间_母婴室_哺乳室_消防_安防_集水坑_基坑_机房_设备_泵房_变配电室_弱电间_接室";
			foreach (Room room in KeyRoom.FilterRoomsByRoomName(lstCurrentLayRoom, strRoomName))
			{
				LocationPoint locationPoint = room.Location as LocationPoint;
				if (locationPoint != null)
				{
					foreach (FloorGeometry floorGeometry in this.m_lstFloorGeometry)
					{
						if (GeometryHelper.PointOnFloor(locationPoint.Point, floorGeometry.m_lstBaseCv))
						{
							list.AddRange(this.CreateRoomLevelDim(room, floorGeometry.m_strLevelVal));
							break;
						}
					}
				}
			}
			return list;
		}

		private List<SingleLevelDimDataInfo> CreateKeyRoomLevelDim(List<Room> lstCurrentLayRoom)
		{
			List<SingleLevelDimDataInfo> list = new List<SingleLevelDimDataInfo>();
			string strRoomName = "大厅_门厅_大堂_前室_电梯厅_侯梯厅_过道_走廊";
			foreach (Room room in new KeyRoom(lstCurrentLayRoom).ClassificationRooms(strRoomName))
			{
				LocationPoint locationPoint = room.Location as LocationPoint;
				if (locationPoint != null)
				{
					foreach (FloorGeometry floorGeometry in this.m_lstFloorGeometry)
					{
						if (GeometryHelper.PointOnFloor(locationPoint.Point, floorGeometry.m_lstBaseCv))
						{
							list.AddRange(this.CreateRoomLevelDim(room, floorGeometry.m_strLevelVal));
							break;
						}
					}
				}
			}
			return list;
		}

		private List<SingleLevelDimDataInfo> CreateRoomLevelDim(Room room, string strLevelVal)
		{
			List<SingleLevelDimDataInfo> list = new List<SingleLevelDimDataInfo>();
			if (room == null)
			{
				return list;
			}
			List<RoomTag> lstRoomTagInRoom = Room2RoomTag.GetInstance().GetLstRoomTagInRoom(room);
			if (lstRoomTagInRoom.Count == 0)
			{
				LocationPoint locationPoint = room.Location as LocationPoint;
				if (locationPoint == null)
				{
					return list;
				}
				SingleLevelDimDataInfo singleLevelDimDataInfo = this.CreateRoomLevelDimByPoint(locationPoint.Point, strLevelVal);
				if (singleLevelDimDataInfo != null)
				{
					list.Add(singleLevelDimDataInfo);
				}
			}
			else
			{
				foreach (RoomTag roomTag in lstRoomTagInRoom)
				{
					LocationPoint locationPoint2 = roomTag.Location as LocationPoint;
					if (locationPoint2 != null && !roomTag.Room.Name.Contains("楼梯"))
					{
						BoundingBoxXYZ boundingBoxXYZ = roomTag.get_BoundingBox(this.m_doc.ActiveView);
						XYZ pt = new XYZ((boundingBoxXYZ.Min.X + boundingBoxXYZ.Max.X) / 2.0, boundingBoxXYZ.Min.Y, locationPoint2.Point.Z);
						SingleLevelDimDataInfo singleLevelDimDataInfo2 = this.CreateRoomLevelDimByPoint(pt, strLevelVal);
						if (singleLevelDimDataInfo2 != null)
						{
							list.Add(singleLevelDimDataInfo2);
						}
					}
				}
			}
			return list;
		}

		private SingleLevelDimDataInfo CreateRoomLevelDimByPoint(XYZ pt, string strLevelVal)
		{
			pt -= XYZ.BasisY * Common.MMToFeet((double)(800 * (this.m_doc.ActiveView.Scale / 100)));
			FamilyInstance familyInstance = new LevelDimData(this.m_doc)
			{
				PtDimLocation = pt,
				DimVal = strLevelVal
			}.CreateLevelDim();
			if (familyInstance == null)
			{
				return null;
			}
			CurveLoop levelDimCurveLoop = OcclusionArea.GetLevelDimCurveLoop(this.m_doc, familyInstance);
			this.m_lstAllCurLayerCurveLoop.Add(levelDimCurveLoop);
			AnnotationSymbol annotationSymbol = familyInstance as AnnotationSymbol;
			if (annotationSymbol == null)
			{
				return null;
			}
			return new SingleLevelDimDataInfo(annotationSymbol)
			{
				LevelVal = this.m_lstFloorGeometry[0].m_dLevelVal,
				DimDir = XYZ.BasisX,
				PtLocation = pt
			};
		}

		private List<CurveLoop> m_lstAllCurLayerCurveLoop = new List<CurveLoop>();

		private Document m_doc;

		private List<FloorGeometry> m_lstFloorGeometry = new List<FloorGeometry>();

		private bool m_bIsCurrentLay;

		private string m_strLevelVal = string.Empty;

		private double m_dLevelVal;

		private List<Room> m_lstCurrentLayRoom = new List<Room>();

		private PlanarFace m_ComponentInSlopePlanarFace;

		private List<SingleLevelDimDataInfo> m_lstHouseSingleDimDataInfo = new List<SingleLevelDimDataInfo>();
	}
}
